//
// Created by buyongjiu on 2024/4/20.
//

#ifndef FEI_LAXER_NFA_H
#define FEI_LAXER_NFA_H

#include <string>
#include <vector>
#include <map>
#include <set>

#include "Grammar.h"

enum Type_t {START, NORMAL, END};

struct NFA_struct{
    Type_t type;
    std::string nowState;
    std::map<std::string, std::set<std::string>> gotoState;
    NFA_struct()= default;
    NFA_struct(Type_t t, std::string nowstate);
    int addEdge(std::string input, std::string next);
};

class NFA {
public:
    int createNFA(const Grammar &G);
    void PrintNFA();
    std::map<std::string, NFA_struct *> nameToStruct;
    std::set<std::string> alphabet;
    std::vector<NFA_struct *> Structs;
    std::set<std::string> state;
};


#endif //FEI_LAXER_NFA_H
